"""
操作mysql演示
"""
from pymysql import Connection

# 构建mysql连接
conn = Connection(
    host='192.168.111.128',
    port=3306,
    user='root',
    password='1234'
)

# 打印服务器版本信息
print(conn.get_server_info())

# 获取游标对象
cursor = conn.cursor()

# 选择数据库
conn.select_db("hive")

# 执行sql
cursor.execute("select * from tbls")

result = cursor.fetchall()
print(result)
print(type(result))  # 输出结果是嵌套元组

for r in result:
    print(r)

# 关闭连接
conn.close()
